<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('rd_message', function (Blueprint $table) {
            $table->comment('消息表');
            $table->bigIncrements('id')->comment('消息ID');
            $table->unsignedInteger('type')->comment('消息类型1预警2反馈3系统');
            $table->string('title', 255)->nullable()->comment('消息标题');
            $table->text('content')->comment('消息内容');
            $table->json('extra')->nullable()->comment('额外信息');
            $table->unsignedInteger('related_id')->default(0)->comment('关联ID');
            $table->unsignedTinyInteger('level')->comment('消息级别1普通2重要3紧急');
            $table->softDeletes();
            $table->datetimes();
            
            // 添加索引
            $table->index('type', 'idx_type');
            $table->index('level', 'idx_level');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('rd_message');
    }
};